import request from '@/utils/request'

export function fetchFactoryBatchOrder(query) {
  return request({
    url: '/factoryBatchOrder/getList.json',
    method: 'get',
    params: query || {}
  })
}

export function fetchFactoryBatchOrderDetail(query) {
  return request({
    url: '/factoryBatchOrder/getDetailList.json',
    method: 'get',
    params: query || {}
  })
}

export function fetchFactoryBalingSummary(query) {
  return request({
    url: '/factoryBaling/summary.json',
    method: 'get',
    params: query || {}
  })
}

export function factoryBalingDetailList(query) {
  return request({
    url: '/factoryBaling/getDetailList.json',
    method: 'get',
    params: query || {}
  })
}

export function factoryBatchOrderByCode(query) {
  return request({
    url: '/factoryBatchOrder/getByCode.json',
    method: 'get',
    params: query || {}
  })
}

export function factoryBatchPrepareCreate(code, time) {
  return request({
    url: '/factoryBatchOrder/prepareCreate.json',
    method: 'post',
    data: {
      enterBatchCode: code,
      balingTime: time
    }
  })
}

export function factoryBatchCreate(code, cnt, time) {
  return request({
    url: '/factoryBatchOrder/createOrder.json',
    method: 'post',
    data: {
      enterBatchCode: code,
      balingTime: time,
      bagCount: cnt
    }
  })
}

export function fetchFactoryBalingList(query) {
  return request({
    url: '/factoryBaling/getList.json',
    method: 'get',
    params: query || {}
  })
}

export function fetchFactoryBaling(query) {
  return request({
    url: '/factoryBaling/get.json',
    method: 'get',
    params: query || {}
  })
}

export function fetchFactoryBalingByCode(query) {
  return request({
    url: '/factoryBaling/getByCode.json',
    method: 'get',
    params: query || {}
  })
}

export function fetchFactoryBalingManagerType(query) {
  return request({
    url: '/factoryBaling/getManagerType.json',
    method: 'get',
    params: query || {}
  })
}

export function factoryBalingAddDetail(opt) {
  return request({
    url: '/factoryBaling/addDetail.json',
    method: 'post',
    data: {
      batchCode: opt.batchCode,
      type: opt.type, // 1布草 2工作服 3手术服 4传染服
      barcode: opt.barcode || '',
      categoryId: opt.categoryId || '',
      clothesCnt: opt.clothesCnt || '',
      mendCnt: opt.mendCnt || 0
    }
  })
}

export function factoryBalingDelete(query) {
  return request({
    url: '/factoryBaling/delDetail.json',
    method: 'get',
    params: query || {}
  })
}

export function factoryBalingCreate(opt) {
  return request({
    url: '/factoryBaling/create.json',
    method: 'post',
    data: {
      batchCode: opt.batchCode,
      type: opt.type, // 1布草 2工作服 3手术服 4传染服
      departmentId: opt.departmentId || ''
    }
  })
}

export function factoryBalingModifyDetail(opt) {
  return request({
    url: '/factoryBaling/modifyDetail.json',
    method: 'post',
    data: {
      id: opt.id,
      clothesCnt: opt.clothesCnt,
      mendCnt: opt.mendCnt
    }
  })
}

export function factoryBalingPrepareCreate(opt) {
  return request({
    url: '/factoryBaling/prepareCreate.json',
    method: 'post',
    data: {
      batchCode: opt.batchCode,
      type: opt.type // 1布草 2工作服 3手术服 4传染服
    }
  })
}
